package com.test.common.concurrency;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import org.apache.tomcat.util.threads.ThreadPoolExecutor;

public class ThreadPoolDemo {
	private static final int THREAD_POOL_SIZE = 10;
//参考CheckTaxServiceImpl 和ReportFormServiceImpl
	public static void main(String[] args) {

		// Java线程池的完整构造函数
//    	  int corePoolSize, // 线程池长期维持的线程数，即使线程处于Idle状态，也不会回收。
//    	  int maximumPoolSize, // 线程数的上限
//    	  long keepAliveTime, TimeUnit unit, // 超过corePoolSize的线程的idle时长，
//    	                                     // 超过这个时间，多余的线程会被回收。
//    	  BlockingQueue<Runnable> workQueue, // 任务的排队队列
//    	  ThreadFactory threadFactory, // 新线程的产生方式
//    	  RejectedExecutionHandler handler) // 拒绝策略
		ExecutorService executorService = new ThreadPoolExecutor(2, 2, 0, TimeUnit.SECONDS,
				new ArrayBlockingQueue<>(512), // 使用有界队列，避免OOM
				new ThreadPoolExecutor.DiscardPolicy());
		
	    final ExecutorService executorService2 = Executors.newFixedThreadPool(THREAD_POOL_SIZE);

	}
}
